home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / other / mesa / mesa-glut / src-glut.aos / glutextensionsupported.c < prev    next >
C/C++ Source or Header  |  2000-02-23  |  1KB  |  57 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  3.  
  4. /* This program is freely distributable without licensing fees
  5.  * and is provided without guarantee or warrantee expressed or
  6.  * implied. This program is -not- in the public domain. */
  7.  
  8. /*
  9.  * glutExtensionSupported.c
  10.  *
  11.  * Version 1.0  27 Jun 1998
  12.  * by Jarno van der Linden
  13.  * jarno@kcbbs.gen.nz
  14.  *
  15.  * Based on glut_ext.c to work with Amiga GLUT
  16.  *
  17.  */
  18.  
  19. #include <stdlib.h>
  20. #include <string.h>
  21.  
  22. #include "glutstuff.h"
  23.  
  24. int glutExtensionSupported(const char *extension)
  25. {
  26.   static const GLubyte *extensions = NULL;
  27.   const GLubyte *start;
  28.   GLubyte *where, *terminator;
  29.  
  30.   /* Extension names should not have spaces. */
  31.   where = (GLubyte *) strchr(extension, ' ');
  32.   if (where || *extension == '\0')
  33.     return 0;
  34.  
  35.   if (!extensions)
  36.     extensions = glGetString(GL_EXTENSIONS);
  37.   /* It takes a bit of care to be fool-proof about parsing the
  38.    * OpenGL extensions string.  Don't be fooled by sub-strings,
  39.    * etc. */
  40.   start = extensions;
  41.   for (;;) {
  42.     where = (GLubyte *) strstr((const char *)start, extension);
  43.     if (!where)
  44.       break;
  45.     terminator = where + strlen(extension);
  46.     if (where == start || *(where - 1) == ' ') {
  47.       if (*terminator == ' ' || *terminator == '\0') {
  48.     return 1;
  49.       }
  50.     }
  51.     start = terminator;
  52.   }
  53.   return 0;
  54. }
  55.  
  56. /* ENDCENTRY */
  57.